import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 123
 * Date: 2023-05-31
 * Time: 20:39
 */
public class Solution {
    public List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> ret = new ArrayList<>() ;
        if(root == null){
            return ret ;
        }
        List<Integer> leftNode = postorderTraversal(root.left);
        ret.addAll(leftNode) ;
        List<Integer> rightNode = postorderTraversal(root.right);
        ret.addAll(rightNode) ;
        ret.add(root.val) ;
        return ret ;
    }
    
}
